<?php

class Form_JobForm extends Form_Custom_General {

    public function init() {

        $job_id = $this->createElement('hidden', 'job_id')
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($job_id);

        $job_code = $this->createElement('text', 'job_code')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Job code should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "60"));
        $this->addElement($job_code);

        $job_description = $this->createElement('textarea', 'job_description')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Description should not be blank.')))
                ->addFilters(array(
                    new Zend_Filter_StringTrim()
                ))
                ->setAttribs(Array("size" => "60", "cols" => "50", "rows" => "10"));
        $this->addElement($job_description);

        $job_uom = $this->createElement('select', 'job_uom')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select unit for job.')));
        $this->addElement($job_uom);
        
        $materialCostValidator = new Zend_Validate_Float();
	$materialCostValidator->setMessage('Material cost should be valid number.');
        $job_materialcost = $this->createElement('text', 'job_materialcost')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Material cost should not be blank.')))
                ->addValidator($materialCostValidator, true)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "20"));
        $this->addElement($job_materialcost);
        
        
        $materialsrpValidator = new Zend_Validate_Float();
	$materialsrpValidator->setMessage('Material srp should be valid number.');
        $job_materialsrp = $this->createElement('text', 'job_materialsrp')
                ->setRequired(TRUE)
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Material srp should not be blank.')))
                ->addValidator($materialsrpValidator, true)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                ))
                ->setAttribs(Array("size" => "20"));
        $this->addElement($job_materialsrp);

        $job_status = $this->createElement('select', 'job_status')
                ->setRequired(TRUE)
                ->addFilters(array(
                    new Zend_Filter_StringTrim(),
                    new Zend_Filter_StringToLower()
                ))
                ->addValidator('NotEmpty', true, array('messages' => array('isEmpty' => 'Please select status.')));
        $this->addElement($job_status);

        $submit = $this->createElement('submit', 'Save')
                ->setAttribs(Array('title' => "Save changes"));
        $this->addElement($submit);


        $reset = $this->createElement('reset', 'Reset')
                ->setAttribs(Array('title' => "Save changes and continue to edit"));
        $this->addElement($reset);
    }

}